/**
 * @namespace DESIGN.Class
 * @author Dave Padovano
 * @date 12.14.2011
 * @description example on how to create a class in javascript that has a singleton instance.
 * inside the class are four  example of functions "private", "public", "getter" & "setter".
 */

//create new namespace object
var DESIGN = DESIGN || {};

DESIGN.Class = (function()
{
	function Class()
	{
		if( !(this instanceof Class) )
		{
			return new DESIGN.Class;
		}

		var self = this,
			_name = null;

		var privateFunction = function()
		{
			//do something private.
		};

		//public method
		self.doSomething = function()
		{
			privateFunction();
		};

		//public setter function
		self.setName = function(value)
		{
			_name = value;
		};

		//public getter function
		self.getName = function()
		{
			return _name;
		};

		return Class;
	}
}());

DESIGN.setName("design patterns rock!");

DESIGN.getName();